﻿using System;
using NLog;
using Entity.Client;
using EncryptionMethods;
using DAL;

public partial class Users : System.Web.UI.Page
{
    #region Variables
    private static Logger _logger = LogManager.GetCurrentClassLogger();
    #endregion

    #region pageload
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            PageTitle.Text = "مستخدم جديد | تسجيل دخول |  LiveKora  لايف كورة";
            Page.MetaDescription = "مستخدم جديد - تسجيل الدخول الى الحساب الخاص بك |  LiveKora  لايف كورة";
        }
        catch (Exception ex)
        {
            _logger.Error("Users:::Page_Load:::" + ex.Message);
        }
    }
    #endregion

    #region Events
    protected void btnRegisterNewUser_Click(object sender, EventArgs e)
    {
        try
        {
            RegUsers objRegUsers = new RegUsers();
            RegisterUsers objRegisterUsers = new RegisterUsers();
            objRegisterUsers.UserFullName = txtUserFullName.Value;
            objRegisterUsers.EmailAddress = txtUserEmailAddress.Text;
            objRegisterUsers.Password = Encryption.Encrypt(txtUserPassword.Value);
            objRegisterUsers.Country = 0;
            objRegisterUsers.UserStatus = 1;
            objRegisterUsers.Type = 2;
            objRegisterUsers.AuthType = 2;
            objRegUsers.InsertNewRegisterUser(objRegisterUsers);
        }
        catch (Exception ex)
        {
            _logger.Error("Users:::btnRegisterNewUser_Click:::" + ex.Message);
        }
    }
    #endregion

    #region webMethods

    //[System.Web.Services.WebMethod]
    //public static string RegisterUser(string fullUserName, string userEmailAddress, string userCountry, string password)
    //{
    //    try
    //    {
    //        RegisterUserService objRegisterUserService = new RegisterUserService();
    //        return objRegisterUserService.RegisterNewUsers(fullUserName, userEmailAddress, userCountry, password, 1, 2, 2).ToString();
    //    }
    //    catch (Exception ex)
    //    {
    //        _logger.Error("Users:::RegisterUser:::" + ex.Message);
    //        return "0";
    //    }
    //}


    [System.Web.Services.WebMethod]
    public static string RegisterUserFacebook(string facebookID, string fullUserName, string userEmailAddress, int userCountry)
    {
        try
        {
            RegisterUserService objRegisterUserService = new RegisterUserService();
            return objRegisterUserService.RegisterNewUsers(facebookID, fullUserName, userEmailAddress, "null", userCountry, 1, 2, 2).ToString();
        }
        catch (Exception ex)
        {
            _logger.Error("Users:::RegisterUser:::" + ex.Message);
            return "0";
        }
    }

    [System.Web.Services.WebMethod]
    public static string IsFacebookRegisterUser(string facebookID)
    {
        try
        {
            RegisterUserService objRegisterUserService = new RegisterUserService();
            return objRegisterUserService.CheckUserRegisterFacebook(facebookID).ToString();
        }
        catch (Exception ex)
        {
            _logger.Error("Users:::IsFacebookRegisterUser:::" + ex.Message);
            return "0";
        }
    }
    #endregion
}